﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet"
        type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(function () {

            InitBar(StartGuideWay.ByParentFlowModel);

            //获取节点属性.
            var flowNo = GetQueryString("FK_Flow");

            $("#Msg").html("正在加载请稍后....");

            var parts = new Entities("BP.WF.Template.Parts");
            parts.Retrieve("PartType", "ParentSubFlowGuide", "FK_Flow", flowNo);

            var strs = "<table style='width:100%;'>";
            strs += "<caption>父流程列表 - <a href='javascript:New();'>新建</a> </caption>";
            strs += "<tr>";
            strs += "<th>流程编号</th>";
            strs += "<th>名称</th>";
            strs += "<th>操作</th>";
            strs += "</tr>";

            for (var i = 0; i < parts.length; i++) {

                var part = parts[i];

                strs += "<tr>";
                strs += "<td>" + part.Tag0 + "</td>";
                strs += "<td>" + part.Tag1 + "</td>";
                strs += "<td><a href=\"javascript:Edit('" + part.MyPK + "');\" >编辑</a></td>";
                strs += "</tr>";
            }
            strs += "</table>";

            $("#Msg").html(strs);

        });

        function New() {

            var flowNo = window.prompt('请输入流程编号');
            if (flowNo == null || flowNo == undefined)
                return;

            var en = new Entity("BP.WF.Flow");
            en.SetPKVal(flowNo);
            var i = en.RetrieveFromDBSources();

            if (i == 0) {
                alert('流程编号输入错误');
                return;
            }

            var flowName = en.Name;
            var myPK = 'ParentSubFlowGuide_' + GetQueryString("FK_Flow") + "_" + flowNo;

            var part = new Entity("BP.WF.Template.Part");
            part.MyPK = myPK;
            part.SetPKVal(myPK);
            if (part.RetrieveFromDBSources() != 0) {
                alert('该流程编号已经存在');
                return;
            }

            //零件.
            var parts = new Entities("BP.WF.Template.Parts");

            //检查该流程是否已经被设置了
            parts.Retrieve("PartType", "ParentSubFlowGuide", "FK_Flow", flowNo);
            if (parts.length != 0) {
                alert('ss');
                return;
            }

            part.FK_Flow = GetQueryString("FK_Flow");
            part.Tag0 = flowNo;
            part.Tag1 = flowName;
            part.Insert();

            var url = "../../../Comm/EnOnly.htm?EnName=BP.WF.Template.PartParentSubGuide&MyPK=" + myPK;
            OpenEasyUiDialogExt(url, '设置父流程', 800, 500, true);
            return;
        }

        function Edit(mypk) {

            var url = "../../../Comm/EnOnly.htm?EnName=BP.WF.Template.PartParentSubGuide&MyPK=" + mypk;
            OpenEasyUiDialogExt(url, '设置父流程', 800, 500, true);
        }

        function Save() {

            //更新节点表单类型.
            var flowNo = GetQueryString("FK_Flow");
            var flow = new Entity("BP.WF.Flow", flowNo);
            flow.StartGuideWay = StartGuideWay.ByParentFlowModel;
            flow.Update();

            window.location.href = window.location.href;
            //alert("保存成功.");
        }
    </script>
</head>
<body>
    <div id="bar">
    </div>

    <table style="width:100%;">
    <tr>
    <td  valign=top  style="width:50%;"> 
    <div id="Msg">
    </div>
     </td>

    <td  valign="top"   style="width:50%;">
    
    <fieldset>
    <legend> 父子流程前置导航 - 帮助</legend>
    <ul>
    <li>发起该流程之前，需要选择一个已经发起的流程实例作为父流程。</li>
    <li>启动该流程的时候，需要启动 /WF/WorkOpt/StartGuideParentFlowModel.htm 的页面，让用户选择一个父流程。</li>
    </ul>
    </fieldset>

    <fieldset>
    <legend> 应用场景</legend>
    <ul>
    <li>在执行财务报销的时候，要选择一个出差申请父流程，并把申请信息带入到报销单里面。</li>
    <li>在执行采购入库的时候，要选择一个采购申请单作为父流程。</li>
    </ul>
    </fieldset>

     </td>
    </tr>
    </table>



    
</body>
</html>
